home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 001a / com_and3.zip / PC-2-PC.CMD < prev    next >
OS/2 REXX Batch file  |  1990-07-10  |  52KB  |  2,042 lines

  1. ; ----- COM-AND Scripted PC-2-PC link
  2. ;    Commenced: 09/20/88 R.McG
  3. ; -----------------------------------------------------------------------
  4. ;    Goals:
  5. ;    o    Must autodetect connection
  6. ;    o    Must dial number on request
  7. ;    o    Must work correctly for modems reporting true CD and
  8. ;        also for direct connects
  9. ;
  10. ;    Functions:
  11. ;    o    Directory list - our current directory
  12. ;    o    Directory list - linked PC directory
  13. ;    o    Change subdirectory - our PC
  14. ;    o    Change subdirectory - linked PC
  15. ;    o    Transfers either way
  16. ; -----------------------------------------------------------------------
  17. ;    Usages:
  18. ;      FLAG(0) -> ON if link established
  19. ;      FLAG(1) -> ON if caller or initiator of connect
  20. ;      FLAG(2) -> Off if we are on 'our' side of the display
  21. ;      FLAG(3) -> On if direct connect
  22. ;
  23. ;      S19 -----> Legend line
  24. ;      S18 -----> Load-time drive:subdirectory (for exit)
  25. ;      S17 -----> Load-time download d:subdir (for exit)
  26. ;
  27. ;      N99 -----> # screen lines
  28. ;      N98 -----> Debugging flag (for one side, two side tests)
  29. ;
  30. ;      N90 -----> Current cursor (1 to N99-5)
  31. ;      N91 -----> # local files selected
  32. ;      N92 -----> # remote files selected
  33. ;
  34. ;      S16 -----> local files selected (13 chars/field)
  35. ;      S15 -----> Remote files selected (13 chars/field)
  36. ;
  37. ;      S12 -----> Used by Change sides for line read/write
  38. ;      S11 -----> Used by various routines for saved file name
  39. ;      S10 -----> Used by various routines for saved ON ESCAPE label
  40. ; -----------------------------------------------------------------------
  41. ;
  42. ;    Initialization
  43. ;
  44. S19 = "PC-2-PC ver 1.1     "    ; 20 chars long
  45. LEGEND S19            ; Set initial legend
  46. SUBDIR S18            ; Read current subdir
  47. DLDIR S17            ; Read current download subdir
  48. SET DLDIR " "                   ; Set download subdir to default
  49. SET FLAG(0) OFF         ; No current link
  50. SET FLAG(1) ON            ; Default - we called/initiated
  51. SET FLAG(2) Off         ; Default - on 'our side' of the display
  52. SET FLAG(3) Off         ; Default - dialed connect
  53. SET CDISP ON            ; Display control chars
  54. SET RDISP OFF            ; Don't display received chars
  55. SET SOFTFLOW OFF        ; Turn off our own flowctl
  56. ;SET HARDFLOW ON        ; Turn on hdwe flowctl
  57. SET ATIME 0            ; Set no alarm time
  58. SET ALARM OFF            ; Set no alarm sound
  59. SET CHAT OFF            ; Set chat off (just in case)
  60. SET XSUI 10            ; Set transer screen update interval
  61. ON ESCAPE GOSUB Exit        ; Escape action
  62. N90 = N91 = N92 = 0        ; Clear # files selected, cursor
  63. S16 = ""
  64. S15 = ""
  65. ;
  66. ;    Make 8n1 for best KERMIT throughput
  67. ;
  68. SET PARITY NONE
  69. SET DATA 8
  70. SET STOP 1
  71. ;
  72. ;    Debugging flag
  73. ;
  74. N98 = 0             ; Debugging if <> zero
  75. ;
  76. ;    Draw the screen, and decide if we're linked
  77. ;
  78. GOSUB InitScreen
  79. GOSUB BuildLocDir        ; Build our directory list
  80. IF ZERO N98            ; Test for debugging
  81.    GOSUB LinkTest        ; Not - make the link
  82. ELSE
  83.    FOPENI "PC2PC.LOC" TEXT      ; Open the file
  84.    ENDIF
  85. ;
  86. ; ----- Update the legend, and accept a command
  87. ;
  88. Main:
  89.     LEGEND S19
  90.     LOCATE (N99-3),77    ; Set the cursor
  91.     SOUND 440,100        ; Indicate we're ready
  92.     SET TTHRU OFF
  93. ;
  94. ;    Loop, waiting for a keypress or received commands
  95. ;
  96. Main100:
  97.     IF HITKEY        ; If a keypress pending
  98.        GOTO MAIN200     ; .. go handle it
  99.        ENDIF
  100.     IF RECEIVE        ; If comm port chars pending
  101.        GOTO MAIN300     ; .. go handle it
  102.        ENDIF
  103.     IF ZERO N98 AND NOT CONNECTED
  104.        GOTO Exit
  105.        ENDIF
  106.     GOTO Main100        ; And loop
  107. ;
  108. ;    We have a keypress pending
  109. ;
  110. MAIN200:
  111.     KEYGET S1        ; Read a single key
  112.     SWITCH S1
  113.        CASE "C"             ; Change directory
  114.           GOSUB ChangeOurDir
  115.        ENDCASE
  116.        CASE "E"             ; Exit
  117.           GOTO Exit     ; And exit
  118.        ENDCASE
  119.        CASE "H"             ; Help
  120.           GOSUB Help
  121.        ENDCASE
  122.        CASE "S"             ; Select
  123.           GOSUB Select
  124.        ENDCASE
  125.        CASE "T"             ; Transfer
  126.           GOSUB Transfer
  127.        ENDCASE
  128.        CASE "W"             ; Wildcard
  129.           GOSUB Wildcard    ; Send using wildcards
  130.        ENDCASE
  131.        CASE "4D00"          ; Cursor_Right
  132.           GOSUB Change_Sides
  133.        ENDCASE
  134.        CASE "4B00"          ; Cursor left
  135.           GOSUB Change_Sides
  136.        ENDCASE
  137.        CASE "4900"          ; PgUp
  138.           GOSUB Prev_Page
  139.        ENDCASE
  140.        CASE "5100"          ; PgDn
  141.           GOSUB Next_Page
  142.        ENDCASE
  143.        CASE "4700"          ; Home
  144.           GOSUB Home_Page
  145.        ENDCASE
  146.        CASE "4F00"          ; End
  147.           GOSUB End_Page
  148.        ENDCASE
  149.        CASE "4800"          ; Cursor Up
  150.           GOSUB Cursor_Up
  151.        ENDCASE
  152.        CASE "5000"          ; Cursor down
  153.           GOSUB Cursor_Down
  154.        ENDCASE
  155.        CASE "7100"          ; Alt-F10
  156.           SHELL
  157.        ENDCASE
  158.        DEFAULT
  159.          SOUND 100,100    ; Signal displeasure
  160.        ENDCASE
  161.     ENDSWITCH
  162.     GOTO Main        ; And continue
  163. ;
  164. ;    We have characters pending on the communications line
  165. ;
  166. MAIN300:
  167.     RGET S1 1        ; Read a single character
  168.     SWITCH S1
  169.        CASE "R"             ; Change directory
  170.           RGET S1 80 10    ; Read remainder
  171.           TRANSMIT "+!"     ; Acknowlege
  172.           GOSUB Remote_Chdir
  173.        ENDCASE
  174.        CASE "E"             ; Sender's local changed
  175.           GOTO Exit
  176.        ENDCASE
  177.        CASE "L"             ; Sender's local changed
  178.           RGET S1 80 10    ; Read remainder
  179.           TRANSMIT "+!"     ; Acknowlege
  180.           GOSUB Local_Chdir
  181.        ENDCASE
  182.        CASE "T"             ; Sender wants to transfer
  183.           RGET S1 80 10    ; Read remainder - note no ACK
  184.           GOSUB Rcv_Transfer
  185.        ENDCASE
  186.        CASE "W"             ; Sender's wants to xfer batch
  187.           RGET S1 80 10    ; Read remainder - note no ACK
  188.           GOSUB Rcv_Wildcard
  189.        ENDCASE
  190. ;       CASE "^M"            ; Carriage rtn
  191. ;       ENDCASE        ; Ignore it
  192.        CASE "?"             ; Link request
  193.           TRANSMIT "PC-2-PC!"
  194.           SET FLAG(1) OFF    ; Indicate we're receiving
  195.           GOSUB Exchange    ; Exchange directories
  196.        ENDCASE        ; Ignore it
  197.        DEFAULT        ; Unrecognized
  198.           RFLUSH        ; Clear line
  199.           GOTO Main100    ; And continue w/o beep
  200.        ENDCASE
  201.     ENDSWITCH
  202.     GOTO Main        ; And continue
  203. ;
  204. ; ----- Exit procedure - ESC has been hit
  205. ;    .. Restore screen, close files and delete temps
  206. ;
  207. Exit:
  208.     IF FLAG (0)        ; If linked
  209.        TRANSMIT "E!"        ; Terminate remote too
  210.        SET FLAG(0) OFF
  211.        ENDIF
  212.     IF CONNECTED and NOT FLAG(3)
  213.        HANGUP        ; Hangup if not direct
  214.        ENDIF
  215.     DO            ; There may be multiple saves outstanding
  216.        RESTORE        ; .. restore all
  217.        UNTIL FAILURE
  218.  
  219.     FCLOSEI         ; CLose files
  220.     FCLOSEO         ; ..
  221.     DELETE "PC2PC.LOC"      ; And delete them too
  222.     DELETE "PC2PC.REM"      ; ..
  223.  
  224.     CHDIR S18        ; Reset current subdir
  225. ; ***    SET HARDFLOW OFF    ; Disable
  226. ;
  227. ; ----- Terminate COM-AND and the script
  228. ;
  229.     SET CDRESPECT ON    ; Skip 'connected' query on exit
  230.     BYE            ; Terminate script AND COM-AND
  231. ;
  232. ; ----- Alternative to above... exit script
  233. ;    .. exchange this paragraph and the above if you want it this way
  234. ;    .. taking off the "***"s
  235. ;
  236. ***    RESET            ; Reset default parameters (bye doesn't care)
  237. ***    EXIT            ; And exit script
  238. ;
  239. ; ----- Subroutine: Clear the current cursor
  240. ;    .. according to the current stting of FLAG(2)
  241. ;
  242. Clear_Cursor:
  243.     IF NOT ZERO N90
  244.        GOSUB Read_Cursor
  245.        IF FLAG(2)        ; IF true we're on remote
  246.           ATSAY N90,41 (default) S12
  247.        ELSE
  248.           ATSAY N90, 2 (default) S12
  249.           ENDIF
  250.        ENDIF
  251.     RETURN
  252. ;
  253. ; ----- Subroutine: Display the current cursor
  254. ;    .. according to the current stting of FLAG(2)
  255. ;
  256. Set_Cursor:
  257.     GOSUB Read_Cursor
  258.     IF NOT ZERO N90
  259.        IF FLAG(2)        ; IF true we're on remote
  260.           IF NOT NULL S12
  261.          ATSAY N90,41 (contrast) S12
  262.           ELSE
  263.          N90 = N90-1
  264.          GOTO Set_Cursor
  265.          ENDIF
  266.        ELSE         ; On own side
  267.           IF NOT NULL S12
  268.          ATSAY N90, 2 (contrast) S12
  269.           ELSE
  270.          N90 = N90-1
  271.          GOTO Set_Cursor
  272.          ENDIF
  273.           ENDIF
  274.        ENDIF
  275.     RETURN
  276. ;
  277. ; ----- Subroutine: Read the line at the current cursor
  278. ;    .. according to the current stting of FLAG(2)
  279. ;    S12 returns the line at the current cursor
  280. ;
  281. Read_Cursor:
  282.     S12 = ""
  283.     IF NOT ZERO N90
  284.        IF FLAG(2)        ; IF true we're on Remote
  285.           ATSCR N90,41,37 S12
  286.        ELSE
  287.           ATSCR N90, 2,37 S12
  288.           ENDIF
  289.        ENDIF
  290.     RETURN
  291. ;
  292. ; ----- Subroutine: Move the cursor Up
  293. ;
  294. Cursor_Up:
  295.     GOSUB Clear_Cursor
  296.     IF NOT ZERO N90
  297.        N90 = N90-1
  298.     ELSE
  299.        N90 = N99-5
  300.        ENDIF
  301.     GOSUB Set_Cursor
  302.     RETURN
  303. ;
  304. ; ----- Subroutine: Move the cursor Down
  305. ;
  306. Cursor_Down:
  307.     GOSUB Clear_Cursor
  308.     IF LT N90 (N99-5)
  309.        N90 = N90+1
  310.     ELSE
  311.        N90 = 1
  312.        ENDIF
  313.     GOSUB Set_Cursor
  314.     RETURN
  315. ;
  316. ; ----- Subroutine: Change the display side
  317. ;
  318. Change_Sides:
  319.     GOSUB Clear_Cursor    ; Clear cursor if any
  320.     N90 = 0         ; Clear current cursor
  321.     IF FLAG(2)        ; IF true we're on remote
  322.        ATSAY N99-4,9  (default) " , , PgUp, PgDn "
  323.        ATSAY N99-4,48 (default) "  to this window "
  324.        SET FLAG(2) OFF
  325.        FOPENI "PC2PC.LOC" TEXT
  326.     ELSE
  327.        ATSAY N99-4,9  (default) "  to this window "
  328.        ATSAY N99-4,48 (default) " , , PgUp, PgDn "
  329.        SET FLAG(2) ON
  330.        FOPENI "PC2PC.REM" TEXT
  331.        ENDIF
  332.     RETURN
  333. ;
  334. ; ----- Subroutine: Clear a window - right or left
  335. ;    .. according to the current stting of FLAG(2)
  336. ;
  337. Clear_Window:
  338.     IF FLAG(2)        ; IF true we're on remote
  339.        SCROLL 0,1,40,(N99-5),77 (default)
  340.     ELSE
  341.        SCROLL 0,1,1,(N99-5),38 (default)
  342.        ENDIF
  343.     N90 = 0         ; Clear current cursor
  344.     RETURN
  345. ;
  346. ; ----- Subroutine: Display the previous page
  347. ;
  348. Prev_Page:
  349.     FRESTOREI        ; Restore pos of top of page
  350.     IF FAILURE        ; If first failed, exit
  351.        RETURN
  352.        ENDIF
  353.     FRESTOREI        ; Restore pos of top of previous page
  354.     IF FAILED        ; If at top of file
  355.        SOUND 100,100    ; Indicate no farther
  356.        ENDIF
  357.     FSAVEI            ; And save again
  358.     GOSUB Clear_Window    ; Clear right or left window
  359. ;
  360. ;    Read the current input file and display
  361. ;
  362. PRPA100:
  363.     N1 = 1            ; Set initial line #
  364. PRPA200:
  365.     READ S1 40 N0        ; Read a line
  366.     IF EOF
  367.        IF EQ N1 1        ; If nothing listed
  368.           GOTO Prev_Page    ; And try again
  369.           ENDIF
  370.        GOTO PRPAXIT     ; Exit on EOF
  371.        ENDIF
  372.     IF FLAG(2)        ; IF true we're on remote
  373.        ATSAY N1,41 (default) S1(0:35)
  374.     ELSE
  375.        ATSAY N1,2  (Default) S1(0:35)
  376.        ENDIF
  377.     INC N1
  378.     IF LE N1 (N99-5)
  379.        GOTO PRPA200
  380.        ENDIF
  381. PRPAXIT:
  382.     RETURN
  383. ;
  384. ; ----- Subroutine:  Display the next page
  385. ;
  386. Next_Page:
  387.     FSAVEI            ; And save again
  388.     GOSUB Clear_Window    ; Clear right or left window
  389.     GOTO PRPA100        ; And Display the page
  390. ;
  391. ; ----- Subroutine:  Set to the home page
  392. ;
  393. Home_Page:
  394.     REWIND            ; Rewind the input file
  395.     FSAVEI CLEAR        ; Clear the stack of positions
  396.     GOTO Next_Page        ; And display the next page
  397. ;
  398. ; ----- Subroutine:  Find the ending page
  399. ;
  400. End_Page:
  401.     FSAVEI            ; Save current position
  402.     GOSUB Clear_Window    ; Clear right or left window
  403. ;
  404. ;    Read the current input file for EOF
  405. ;
  406. ENPA100:
  407.     N1 = 1            ; Set initial line #
  408. ENPA200:
  409.     READ S1 40 N0        ; Read a line
  410.     IF EOF
  411.        IF EQ N1 1        ; Empty page
  412.           FRESTOREI     ; Set saved pos of EOF
  413.           IF FAILURE
  414.          RETURN
  415.          ENDIF
  416.           ENDIF
  417.        GOTO ENPAXIT     ; Exit on EOF
  418.        ENDIF
  419.     INC N1
  420.     IF LE N1 (N99-5)
  421.        GOTO ENPA200
  422.        ENDIF
  423.     FSAVEI            ; Save the current position
  424.     IF FAILED        ; Stack is full
  425.        FSAVEI SHIFT
  426.        FSAVEI
  427.        ENDIF
  428.     GOTO ENPA100        ; Read next page
  429. ;
  430. ;    End of loop
  431. ;
  432. ENPAXIT:
  433.     FSAVEI            ; Save EOF
  434.     IF FAILED        ; Stack is full
  435.        FSAVEI SHIFT
  436.        FSAVEI
  437.        ENDIF
  438.     GOTO PRev_Page        ; And display the previous page
  439. ;
  440. ; ----- Subroutine: Change subdirectory (on either side)
  441. ;
  442. ChangeOurDir:
  443.     IF FLAG(2)        ; We're on remote
  444.        IF NOT ZERO N92
  445.           GOTO CHDI200
  446.           ENDIF
  447.     ELSE
  448.        IF NOT ZERO N91
  449.           GOTO CHDI100
  450.           ENDIF
  451.        ENDIF
  452. ;
  453. ;    Save the current input file name, fully qualified
  454. ;
  455.     IF FLAG(2)        ; We're on remote
  456.        S11 = "PC2PC.REM"
  457.     ELSE
  458.        S11 = "PC2PC.LOC"
  459.        ENDIF
  460.     FFIRST S11
  461.     FNEXT S11 QUAL        ; Get qualified name of file
  462. ;
  463. ;    Ask for a new directory (and set it)
  464. ;
  465.     GOSUB Ask_Dir        ; Ask for subdir
  466.     IF FLAG(9)        ; If ESC out
  467.        RETURN        ; .. no-op
  468.        ENDIF
  469. ;
  470. ;    Close the input file and delete it
  471. ;
  472.     FCLOSEI         ; Close our directory file
  473.     DELETE S11        ; DELETE current PC2PC.LOC
  474. ;
  475. ;    And acquire a new directory
  476. ;
  477.     GOSUB Clear_Window    ; Clear whichever window
  478.     IF FLAG(2)        ; If we're on the remote
  479.        GOSUB BuildRemDir    ; Command remote, and receive new list
  480.     ELSE
  481.        GOSUB SendLocDir    ; Build a new, and send the update
  482.        ENDIF
  483. ;
  484. ;    Reset the input file, and we're done
  485. ;
  486.     IF FLAG(2)        ; We're on remote
  487.        S11 = "PC2PC.REM"
  488.     ELSE
  489.        S11 = "PC2PC.LOC"
  490.        ENDIF
  491.     FOPENI S11 TEXT     ; Open a new input file
  492.     RETURN
  493. ;
  494. ;    Files are selected on the local side
  495. ;    .. Ask if thry're to be deleted
  496. ;
  497. CHDI100:
  498.     S10 = "_ONESCAPE"               ; Save label previously set
  499.     ON ESCAPE GOSUB CHDIEsc     ; Escape out of pop-up
  500.  
  501.     SAVE 10,10,12,70
  502.     BOX  10,10,12,70 (contrast)
  503. CHDI110:
  504.     ATSAY 11,12 (contrast) "Files are selected on local side: Delete? Y/N: "
  505.     ATSAY 12,26 (contrast) " Press ESC to cancel "
  506.  
  507.     KEYGET S1        ; Wait for any key
  508.  
  509.     ON ESCAPE GOSUB S10    ; Reset original ON ESCAPE label
  510.     RESTORE         ; Restore screen under
  511.  
  512.     SWITCH S1
  513.        CASE "N"
  514.           RETURN
  515.        ENDCASE
  516.  
  517.        CASE "Y"
  518.           S16 = ""
  519.           N91 = 0
  520.           GOTO ChangeOurDir ; And continue
  521.        ENDCASE
  522.  
  523.        DEFAULT
  524.           SOUND 100,100
  525.           GOTO CHDI100
  526.        ENDCASE
  527.     ENDSWITCH
  528. ;
  529. ;    Files are selected on the remote side
  530. ;    .. Ask if thry're to be deleted
  531. ;
  532. CHDI200:
  533.     S10 = "_ONESCAPE"               ; Save label previously set
  534.     ON ESCAPE GOSUB CHDIEsc     ; Escape out of pop-up
  535.  
  536.     SAVE 10,10,12,70
  537.     BOX  10,10,12,70 (contrast)
  538.  
  539.     ATSAY 11,12 (contrast) "Files are selected on remote side: Delete? Y/N: "
  540.     ATSAY 12,26 (contrast) " Press ESC to cancel "
  541.  
  542.     KEYGET S1        ; Wait for any key
  543.  
  544.     ON ESCAPE GOSUB S10    ; Reset original ON ESCAPE label
  545.     RESTORE         ; Restore screen under
  546.  
  547.     SWITCH S1
  548.        CASE "N"
  549.           RETURN
  550.        ENDCASE
  551.  
  552.        CASE "Y"
  553.           S15 = ""
  554.           N92 = 0
  555.           GOTO ChangeOurDir ; And continue
  556.        ENDCASE
  557.  
  558.        DEFAULT
  559.           SOUND 100,100
  560.           GOTO CHDI200
  561.        ENDCASE
  562.     ENDSWITCH
  563. ;
  564. ;    Escape during "unimpl" window
  565. ;
  566. CHDIEsc:
  567.     S1 = ""
  568.     RETURN            ; And return to KEYGET above
  569. ;
  570. ; ----- Subroutine: Fatal disc error
  571. ;    .. Open a window, display, and exit
  572. ;
  573. Disc_Error:
  574.     BOX 10,10,12,70 (contrast)
  575.     ATSAY 11,12 (contrast) "Fatal disc error - PC2PC terminating"
  576.     ATSAY 12,26 (contrast) " Press any key to continue "
  577.  
  578.     KEYGET S0        ; Wait for any key
  579.     GOTO Exit        ; And we're done
  580. ;
  581. ; ----- Subroutine: Unimplemented function
  582. ;    .. Open a window, display, and and await keypress
  583. ;    S1,S10 modified
  584. ;
  585. Unimpl:
  586.     S10 = "_ONESCAPE"               ; Save label previously set
  587.     ON ESCAPE GOSUB UnimEsc     ; Escape out of pop-up
  588.  
  589.     SAVE 10,10,12,70
  590.     BOX  10,10,12,70 (contrast)
  591.  
  592.     ATSAY 11,12 (contrast) "Unimplemented function"
  593.     ATSAY 12,26 (contrast) " Press any key to continue "
  594.  
  595.     KEYGET S1        ; Wait for any key
  596.     ON ESCAPE GOSUB S10    ; Reset original ON ESCAPE label
  597.     RESTORE         ; Restore screen under
  598.     RETURN            ; And return to caller
  599. ;
  600. ;    Escape during "unimpl" window
  601. ;
  602. UnimEsc:
  603.     RETURN            ; And return to KEYGET above
  604. ;
  605. ; ----- Build our directory list (a file, PC2PC.LOC, and display)
  606. ;
  607. BuildLocDir:
  608.     FOPENO "PC2PC.LOC" TEXT ; Open, purge if need be
  609.     IF FAILURE
  610.        GOSUB Disc_Error
  611.        ENDIF
  612.  
  613.     FFIRST "*.*"            ; Initialize
  614.     IF Failure        ; If not found
  615.        FCLOSEO        ; Close (and flush) output file
  616.        RETURN        ; Quit here
  617.        ENDIF
  618.  
  619.     N1 = 1            ; Set loop counter
  620. ;
  621. ;    Read and display the file names
  622. ;
  623. BULD100:
  624.     FNEXT S1        ; Get next file name
  625.     IF Failure        ; If end of list
  626.        FCLOSEO        ; Close (and flush) output file
  627.        RETURN        ; Quit
  628.        ENDIF
  629. ;
  630. ;    Skip our own files
  631. ;
  632.     IF STRCMP S1 "PC2PC.LOC"
  633.        GOTO BULD100     ; SKip this file
  634.        ENDIF
  635.     IF STRCMP S1 "PC2PC.REM"
  636.        GOTO BULD100     ; SKip this file
  637.        ENDIF
  638.     IF STRCMP S1(1:1) "."   ; Skip parent subdir
  639.        GOTO BULD100     ; SKip this file
  640.        ENDIF
  641. ;
  642. ;    Handle subdirectories
  643. ;
  644.     FATTR S2 S1        ; Get attribute
  645.     IF STRCMP S2(3:3) "1"   ; If a subdirectory
  646.        GOTO BULD100     ; Goto endloop
  647.        ENDIF
  648. ;
  649. ;    Get remaining information and build the display line
  650. ;
  651.     FSIZE S2 S1        ; Get file size
  652.     FDATE S3 S1        ; Get file date
  653.     FTIME S4 S1        ; Get file time
  654.     S1(13:79) = S2        ; Set size
  655.     S1(21:79) = S3        ; Set date
  656.     S1(31:79) = S4        ; Set time
  657.     S1(39) = " "            ; Make last char blank
  658. ;
  659. ;    Write the information to disc, and display the line
  660. ;
  661.     IF GE (N99-5),N1     ; If within window
  662.        ATSAY N1,2 (default) S1(0:35) ; And display
  663.        ENDIF
  664.     WRITE S1 40        ; Write the line to disc too
  665.     INC N1            ; Count the line
  666.     GOTO BULD100        ; And continue
  667. ;
  668. ; ----- Subroutine: Test if we're linked
  669. ;
  670. LinkTest:
  671.     IF NOT CONNECTED    ; Test for carrier
  672.        GOTO NoLink        ; There can be no link
  673.        ENDIF
  674.     LEGEND " Testing for link"
  675. ;
  676. ;    Build an enquiry and wait for a response
  677. ;
  678.     RFLUSH            ; Clear pipe
  679.     TRANSMIT "!?!"          ; ? = enquiry
  680.     RGET S1 80 10        ; 10 second timeout - read the line
  681. ;
  682. ;    Interpret the response
  683. ;
  684.     IF FAILURE        ; If nothing received
  685.        GOTO NoLink        ; There is no link
  686.        ENDIF
  687.     IF NOT STRCMP S1 "PC-2-PC"
  688.        GOTO NoLink        ; Incorrect response
  689.        ENDIF
  690. ;
  691. ;    Exchange directory files
  692. ;
  693.     GOSUB Exchange        ; Exchange directories
  694.     IF NOT FLAG(0)        ; Exchange failed
  695.        GOTO NoLink
  696.        ENDIF
  697. ;
  698. ;    Flag that link has been established
  699. ;
  700. LinkXIT:
  701.     S19(20:79) = "Linked"
  702.     RETURN
  703. ;
  704. ;    Flag no link available
  705. ;    .. Note: Escape from here terminates the script
  706. ;
  707. NoLink:
  708.     RFLUSH            ; Clear pipe
  709.     LEGEND " Select link method"
  710.     SET FLAG(0) OFF
  711.     SAVE 8,10,21,70     ; Save for restore
  712.     BOX  8,10,21,70 (contrast)
  713.  
  714.     ATSAY  9,12 (contrast) "No link is detected: select one of the following:"
  715.     ATSAY 11,12 (contrast) "1) Direct connect "
  716.     ATSAY 12,12 (contrast) "2) Wait for direct connect"
  717.     ATSAY 14,12 (contrast) "3) Dial the remote PC"
  718.     ATSAY 15,12 (contrast) "4) Wait for call connect "
  719.     ATSAY 17,12 (contrast) "5) Change subdirectory "
  720.     ATSAY 18,12 (contrast) "6) Help"
  721.     ATSAY 20,12 (Contrast) "Select: "
  722.     ATSAY 21,28 (Contrast) " ESC terminates script "
  723. ;
  724. ;    Read the kbd for a response
  725. ;
  726. NOLI100:
  727.     LOCATE 20,21
  728.     KEYGET S1        ; Wait for any key
  729.     SWITCH S1        ; Act upone the entry
  730.        CASE "1"             ; Direct
  731.           GOSUB Direct    ; Set-up direct
  732.           IF not FLAG(9)    ; If escaped out
  733.          GOTO NOLI100    ; Ask again
  734.          ENDIF
  735.           CLOG "* PC-2-PC Direct connect attempt"
  736.           SET FLAG(3) ON    ; Flag fact
  737.           RESTORE        ; Drop select window
  738.        ENDCASE
  739.  
  740.        CASE "2"             ; Await direct
  741.           GOSUB Await_Direct
  742.           IF not FLAG(9)    ; If escaped out
  743.          GOTO NOLI100    ; Ask again
  744.          ENDIF
  745.           GOSUB Respond    ; Wait for prompt
  746.           IF FLAG(1)    ; We didn't get the prompt
  747.          SOUND 880,500    ; Indicate problem
  748.          GOTO NOLI100
  749.          ENDIF
  750.           RESTORE        ; Drop select window
  751.           GOSUB Exchange    ; Exchange directories
  752.           IF FLAG(0)    ; We are connected
  753.          CLOG "* PC-2-PC Direct connect done"
  754.          SET FLAG(3) ON ; Flag fact
  755.          GOTO LinkXIT    ; Exit LINKTEST
  756.          ENDIF
  757.        ENDCASE
  758.  
  759.        CASE "3"             ; Dial out
  760.           GOSUB Dial    ; Unimplemented
  761.           IF FLAG(9)    ; No connect indicated
  762.          GOTO NOLI100    ; .. or ESCAPE
  763.          ENDIF
  764.           CLOG "* PC-2-PC Dial done"
  765.           RESTORE        ; Drop select window
  766.        ENDCASE
  767.  
  768.        CASE "4"             ; Wait for call connect
  769.           GOSUB Await_Call    ; .. wait for connect
  770.           IF FLAG(9)    ; No connect indicated
  771.          GOTO NOLI100    ; .. or ESCAPE
  772.          ENDIF
  773.           GOSUB Respond    ; Wait for prompt
  774.           IF FLAG(1)    ; We didn't get the prompt
  775.          SOUND 880,500    ; Indicate problem
  776.          GOTO NOLI100
  777.          ENDIF
  778.           RESTORE        ; Clear window
  779.           GOSUB Exchange    ; Exchange directoroes
  780.           IF FLAG(0)    ; We are connected
  781.          CLOG "* PC-2-PC Dial auto-answer"
  782.          GOTO LinkXIT
  783.          ENDIF
  784.        ENDCASE
  785.  
  786.        CASE "5"             ; Set new subdirectory
  787.           FFIRST "PC2PC.LOC"
  788.           FNEXT S11 QUAL     ; Get qualified name of file
  789.           GOSUB Change_Dir    ; Ask for subdir
  790.           IF FLAG(9)    ; If ESC out
  791.          GOTO NOLI100    ; .. ask again
  792.          ENDIF
  793.           FCLOSEI        ; Close our directory file
  794.           DELETE S11    ; DELETE old PC2PC.LOC
  795.           RESTORE        ; Drop the current window
  796.           SCROLL 0,1,1,(N99-5),38 (default)
  797.           GOSUB BuildLocDir ; Redo the directory build
  798.           FOPENI "PC2PC.LOC" TEXT
  799.           GOTO NoLink    ; And redisplay window
  800.        ENDCASE
  801.  
  802.        CASE "6"             ; Help
  803.           GOSUB Help    ; Do a help screen
  804.           GOTO NOLI100    ; and read again
  805.        ENDCASE
  806.  
  807.        DEFAULT        ; None of the above
  808.          SOUND 100,100    ; Signal displeasure
  809.          GOTO NOLI100
  810.        ENDCASE
  811.     ENDSWITCH
  812. ;
  813. ;    We get here after one of the 'active' cases above
  814. ;
  815. ;***    PAUSE 3         ; Wait a bit
  816.     GOTO LinkTest        ; Go test again
  817. ;
  818. ; ----- Subroutine: Set-up and execute a direct connect
  819. ;    Flag(9) Is returned true if caller ESCapes
  820. ;    S1,S10 modified
  821. ;
  822. Direct:
  823.     SET CDRESPECT OFF    ; Turn off carrier respect
  824.     GOSUB Set_Parms     ; Set comm parms
  825.     RFLUSH            ; Clear line
  826.     RETURN
  827. ;
  828. ; ----- Subroutine: Await the a direct line
  829. ;    S1,S10 modified
  830. ;    Flag(9) Is returned true if caller ESCapes
  831. ;
  832. Await_Direct:
  833.     SET CDRESPECT OFF    ; Turn off carrier detect
  834.     GOSUB Set_Parms     ; Set comm parms
  835.     RFLUSH            ; Clear line
  836.     RETURN            ; And return
  837. ;
  838. ; ----- Subroutine: Set-up communications parms
  839. ;    FLAG (9) if rtnd true -> ESCAPE
  840. ;    S1,S10 modified
  841. ;
  842. Set_parms:
  843.     WOPEN 8,10,15,70 (Contrast) SEPAESC
  844.     SET FLAG(9) ON
  845.  
  846.     ATSAY  8,12 (contrast) " Direct connection - set parameters"
  847.     ATSAY  9,12 (contrast) "Select any of the following, CR to begin:"
  848.     ATSAY 10,12 (contrast) "A) COM1"
  849.     ATSAY 11,12 (contrast) "B) COM2"
  850.     ATSAY 12,12 (contrast) "C) COM3"
  851.     ATSAY 13,12 (contrast) "D) COM4"
  852.     ATSAY 10,22 (contrast) "1) 300"
  853.     ATSAY 11,22 (contrast) "2) 1200"
  854.     ATSAY 12,22 (contrast) "3) 2400"
  855.     ATSAY 13,22 (contrast) "4) 4800"
  856.     ATSAY 10,32 (contrast) "5) 9600"
  857.     ATSAY 11,32 (contrast) "6) 19.2"
  858.     ATSAY 12,32 (contrast) "7) 38.4K"
  859.     ATSAY 13,32 (contrast) "8) 56.6K"
  860.     ATSAY 10,42 (contrast) "9) 115K"
  861.     ATSAY 11,42 (contrast) "Note: 115K may yield"
  862.     ATSAY 12,42 (contrast) "a high error rate on"
  863.     ATSAY 13,42 (contrast) "many async boards"
  864.  
  865.     ATSAY 14,12 (contrast) "Current setting: "
  866.     ATSAY 15,29 (contrast) " Press ESC to cancel "
  867. SEPA100:
  868.     COMPARMS S1        ; Read current setting
  869.     ATSAY 14,29 (CONTRAST) S1(0:14)
  870.  
  871.     KEYGET S1        ; Wait for any key
  872.     SWITCH S1        ; Act upone the entry
  873.        CASE "0D"            ; Test for c/r entry
  874.           WCLOSE        ; Reset original ON ESCAPE label, and close window
  875.           RETURN        ; Return to caller if so
  876.        ENDCASE
  877.        CASE "A"
  878.           SET PORT COM1
  879.        ENDCASE
  880.        CASE "B"
  881.           SET PORT COM2
  882.        ENDCASE
  883.        CASE "C"
  884.           SET PORT COM3
  885.        ENDCASE
  886.        CASE "D"
  887.           SET PORT COM4
  888.        ENDCASE
  889.        CASE "1"
  890.           SET BAUD 300
  891.        ENDCASE
  892.        CASE "2"
  893.           SET BAUD 1200
  894.        ENDCASE
  895.        CASE "3"
  896.           SET BAUD 2400
  897.        ENDCASE
  898.        CASE "4"
  899.           SET BAUD 4800
  900.        ENDCASE
  901.        CASE "5"
  902.           SET BAUD 9600
  903.        ENDCASE
  904.        CASE "6"
  905.           SET BAUD 19K
  906.        ENDCASE
  907.        CASE "7"
  908.           SET BAUD 38K
  909.        ENDCASE
  910.        CASE "8"
  911.           SET BAUD 56K
  912.        ENDCASE
  913.        CASE "9"
  914.           SET BAUD 115K
  915.        ENDCASE
  916.        DEFAULT
  917.          SOUND 100,100    ; Signal displeasure
  918.        ENDCASE        ; End
  919.     ENDSWITCH
  920.     GOTO SEPA100
  921. ;
  922. ;    Escape during Set_Parms menu
  923. ;
  924. SEPAEsc:
  925.     S1 = "0D"               ; Fake a c/r entered
  926.     SET FLAG(9) OFF     ; Turn off rtn flag
  927.     RETURN            ; And return to KEYGET above
  928. ;
  929. ; ----- Subroutine: Dial another PC - stubbed for test purposes
  930. ;    S1,S10 modified
  931. ;    FLAG(9) Returned true -> error in dialing
  932. ;
  933. Dial:
  934.     S10 = "_ONESCAPE"       ; Save label previously set
  935.     ON ESCAPE GOSUB DialEsc ; Escape out of pop-up
  936.     LEGEND " Dialing remote PC"
  937.  
  938.     SAVE 10,10,12,70
  939.     BOX  10,10,12,70 (contrast)
  940.  
  941.     ATSAY 11,12 (contrast) "Enter number to be dialed: "
  942.     ATSAY 12,29 (contrast) " Press ESC to cancel "
  943. Dial100:
  944.     SET FLAG (9) ON     ; Indicate error
  945.     ATGET 11,39 (contrast) 4 S1 ;We expect no more than 4 chars
  946.     IF NULL S1
  947.        GOTO DialXIT     ; And exit
  948.        ENDIF
  949.     DIAL S1         ; Dial # given
  950.     IF FAILED        ; IF DIAL failed
  951.        SOUND 880,500    ; Indicate problem
  952.        GOTO Dial100     ; Ask again
  953.        ENDIF
  954.     CLOG "* PC-2-PC Dialed: "*"_call"
  955.     SET FLAG (9) OFF
  956. DialXIT:
  957.     ON ESCAPE GOSUB S10    ; Reset original ON ESCAPE label
  958.     RESTORE         ; Restore screen under
  959.     RETURN            ; And return to caller
  960. ;
  961. ;    Escape during "Dial" window
  962. ;
  963. DialEsc:
  964.     S1 = ""                 ; Make a null return
  965.     RETURN            ; And return to KEYGET above
  966. ;
  967. ; ----- Subroutine: Await a call from the remote PC
  968. ;    S1,S10 modified
  969. ;    FLAG(9) Returns true if ESC is taken
  970. ;
  971. Await_Call:
  972.     S10 = "_ONESCAPE"       ; Save label previously set
  973.     ON ESCAPE GOSUB AWCAEsc ; Escape out of pop-up
  974.     LEGEND " Waiting for call"
  975.  
  976.     SAVE 10,10,12,70
  977.     BOX  10,10,12,70 (contrast)
  978.  
  979.     ATSAY 11,12 (contrast) "Waiting for call from remote"
  980.     ATSAY 12,26 (contrast) " Press ESC to terminate "
  981. ;
  982. ;    Go into auto answer (echo off, answer on 2nd)
  983. ;    Also: Return result codes, word form, with CONNECT 1200
  984. ;
  985.     SET PARITY NONE         ; Turn off parity
  986.     SET DATA 8            ; Set 8 databits
  987.     SET MASK ON            ; Mask received text to 7 bits
  988.     SET FLAG(9) OFF         ; Assume OK
  989. AWCA100:
  990.     Pause 3             ; Wait 3 seconds
  991.     HANGUP                ; HANGUP and leave modem in cmd mode
  992.     PAUSE 3             ; Wait 3 secs
  993.     TRANSMIT "ATE0Q0V1X1S0=2 S7=30 S9=10^M"
  994. ;
  995. ;    Wait for a connect
  996. ;
  997. AWCA200:
  998.     RGET S1 80 180            ; Wait for a line
  999.     IF NOT SUCCESS            ; If nothing was read
  1000.        GOTO AWCAXIT         ; Exit on timeout or ESCape
  1001.        ENDIF
  1002.  
  1003.     FIND S1 "NO CARRIER"            ; Look for a disconn
  1004.     IF FOUND
  1005.        GOTO AWCA100
  1006.        ENDIF
  1007.  
  1008.     FIND S1 "CONNECT"               ; Anything else BUT CONNECT
  1009.     IF NOT FOUND            ; .. waits
  1010.        GOTO AWCA200
  1011.        ENDIF
  1012.  
  1013. ;***    IF NOT CONNECTED        ; Some modems don't seem fast enough
  1014. ;***       GOTO AWCA200
  1015. ;***       ENDIF
  1016. ;
  1017. ;    Change baud rate according to connect
  1018. ;
  1019.     FIND S1 "1200"                  ; Test for 1200 baud
  1020.     IF FOUND            ; IF found
  1021.        SET BAUD 1200        ; Set to 1200 baud
  1022.        GOTO AWCAXIT         ; We're done.
  1023.        ENDIF
  1024.  
  1025.     FIND S1 "2400"                  ; Test for 1400 baud
  1026.     IF FOUND            ; IF found
  1027.        SET BAUD 2400        ; Set to 1400 baud
  1028.        GOTO AWCAXIT         ; We're done.
  1029.        ENDIF
  1030. ;
  1031. ;    None of the above... set to 300
  1032. ;
  1033.     SET BAUD 300            ; Set to 1200 baud
  1034. ;
  1035. ;    We have connect (or ESCAPE)
  1036. ;
  1037. AWCAXIT:
  1038.     ON ESCAPE GOSUB S10    ; Reset original ON ESCAPE label
  1039.     RESTORE         ; Restore screen under
  1040.     RETURN            ; And return to caller
  1041. ;
  1042. ;    Escape during "Await" window
  1043. ;
  1044. AWCAEsc:
  1045.     SET FLAG(9) ON        ; Indicate escape
  1046.     RETURN            ; And return to KEYGET above
  1047. ;
  1048. ; ----- Subroutine: Change subdirectory
  1049. ;    FLAG(9) Returned true -> error or ESCAPE
  1050. ;
  1051. Change_Dir:
  1052.     GOSUB Ask_Dir
  1053.     IF NOT FLAG(9)
  1054.        CHDIR S1           ; Change subdirectory
  1055.        ENDIF
  1056.     RETURN
  1057. ;
  1058. ; ----- Subroutine: Query for a new subdirectory
  1059. ;    S1    Returns response
  1060. ;    FLAG(9) Returned true -> error or ESCAPE
  1061. ;
  1062. Ask_Dir:
  1063.     S10 = "_ONESCAPE"       ; Save label previously set
  1064.     ON ESCAPE GOSUB ASDIEsc ; Escape out of pop-up
  1065.  
  1066.     SAVE 10,1,12,77
  1067.     BOX  10,1,12,77 (contrast)
  1068.  
  1069.     ATSAY 11, 3 (contrast) "Enter new subdirectory: "
  1070.     ATSAY 12,28 (contrast) " Press ESC to cancel "
  1071. ASDI100:
  1072.     SET FLAG (9) ON     ; Indicate error
  1073.     ATGET 11,27 (contrast) 50 S1 ; Read response
  1074.     IF NOT NULL S1        ; Look for a null response
  1075.        SET FLAG (9) OFF
  1076.        ENDIF
  1077.  
  1078.     ON ESCAPE GOSUB S10    ; Reset original ON ESCAPE label
  1079.     RESTORE         ; Restore screen under
  1080.     RETURN            ; And return to caller
  1081. ;
  1082. ;    Escape during "Dial" window
  1083. ;
  1084. ASDIEsc:
  1085.     S1 = ""                 ; Make a null return
  1086.     RETURN            ; And return to KEYGET above
  1087. ;
  1088. ; ----- Subroutine: Wait for ENQ and respond
  1089. ;    .. FLAG (1) is set false upon successful completion
  1090. ;    S1,N1 modified
  1091. ;
  1092. Respond:
  1093.     LEGEND " Waiting for prompt"
  1094.     S10 = "_ONESCAPE"       ; Save label previously set
  1095.     ON ESCAPE GOSUB RESPEsc ; Escape out of pop-up
  1096.  
  1097.     SAVE 10,10,12,70
  1098.     BOX  10,10,12,70 (contrast)
  1099.  
  1100.     ATSAY 11,12 (contrast) "Waiting for prompt from remote"
  1101.     ATSAY 12,26 (contrast) " Press ESC to cancel "
  1102. RESP100:
  1103.     RGET S1 80,120        ; Wait 2 mins
  1104.     IF SUCCESS and NULL S1    ; If empty line rcv'd
  1105.        GOTO Resp100     ; Loop
  1106.        ENDIF
  1107.     IF SUCCESS and STRCMP S1(0:0) "?"   ; If enquiry received
  1108.        TRANSMIT "PC-2-PC!"  ; Transmit response
  1109.        SET FLAG(1) OFF    ; Indicate we're receiving
  1110.        ENDIF
  1111.  
  1112.     ON ESCAPE GOSUB S10    ; Reset original ON ESCAPE label
  1113.     RESTORE         ; Restore screen under
  1114.     LEGEND S19        ; Replace legend
  1115.     RETURN            ; And exit
  1116. ;
  1117. ;    Escape while waiting for prompt
  1118. ;
  1119. RESPEsc:
  1120.     S1 = "ESCAPE"           ; Make it non-null
  1121.     RETURN
  1122. ;
  1123. ; ----- Subroutine: Exchange subdirectory files
  1124. ;    .. FLAG (0) is set true upon successful completion
  1125. ;    S1,S2 N1,N2,N3,N4,N5 modified
  1126. ;
  1127. Exchange:
  1128.     FOPENO "PC2PC.REM" TEXT ; Open remote directory, purge if need be
  1129.     IF FAILURE
  1130.        GOSUB Disc_Error
  1131.        ENDIF
  1132.     FOPENI "PC2PC.LOC" TEXT ; Open our directory
  1133.     IF FAILURE
  1134.        GOSUB Disc_Error
  1135.        ENDIF
  1136.     LEGEND "Exchanging directory listings"
  1137. ;
  1138. ;    Initialize for a loop
  1139. ;
  1140.     N1 = 1            ; Screen line #
  1141.     N5 = 0            ; Error tracker
  1142.     IF FLAG(1)        ; If we're initiator
  1143.        GOTO EXCH200
  1144.        ENDIF
  1145. ;
  1146. ;    Wait for a response
  1147. ;    .. Comments removed from below to speed
  1148. ;
  1149. EXCH100:
  1150.     RGET S2 80 15
  1151.     IF Failure
  1152.        GOTO EXCHXIT
  1153.        ENDIF
  1154. ;
  1155. ;    Handle received NAK
  1156. ;
  1157.     IF NOT STRCMP S2(0:0) "+"
  1158.        INC N5
  1159.        IF GT N5,20
  1160.           GOTO EXCHXIT
  1161.           ENDIF
  1162.        GOTO EXCH210     ; Retransmit
  1163.        ENDIF
  1164. ;
  1165. ;    Perform a CRC check
  1166. ;
  1167.     LENGTH S2 N3
  1168.     IF GT N3 1
  1169.        CRC S2(1:40) N2
  1170.        ATOI S2(41:46) N4
  1171.        IF NE N2 N4
  1172.           GOTO EXCHERR
  1173.           ENDIF
  1174. ;
  1175. ;    1 character rcvd (ACK)
  1176. ;
  1177.     ELSE
  1178.        IF EOF
  1179.           TRANSMIT "+!"
  1180.           SET FLAG(0) ON
  1181.           GOTO EXCHXIT
  1182.           ENDIF
  1183.        LEGEND S19(0:19)&" Line "*N1&" exchanged"
  1184.        INC N1
  1185.        GOTO EXCH200
  1186.        ENDIF
  1187. ;
  1188. ;    Save the rcvd, and display
  1189. ;
  1190.     IF GE (N99-5),N1
  1191.        ATSAY N1,41 (default) S2(1:36)
  1192.     ELSE
  1193.        IF EQ (N99-4) N1
  1194.           FSAVEI
  1195.           ENDIF
  1196.        LEGEND S19(0:19)&" Line "*N1&" exchanged"
  1197.        ENDIF
  1198.     WRITE S2(1:40) 40
  1199.     INC N1
  1200. ;
  1201. ;    Send a line from our file
  1202. ;
  1203. EXCH200:
  1204.     N5 = 0
  1205.     READ S1 40 N2        ; Length read into N2
  1206.     IF EOF
  1207.        S1 = "!"             ; Make an cr line
  1208.        GOTO EXCH210     ; And and continue
  1209.        ENDIF
  1210.     CRC S1(0:39) N2     ; CRC what we read
  1211.     S1(40:50) = N2 &"!"     ; Place CRC and c/r into string
  1212. ;
  1213. ;    Transmit the line
  1214. ;
  1215. EXCH210:
  1216.     TRANSMIT "+"&S1
  1217.     GOTO EXCH100
  1218. ;
  1219. ;    Error on received line
  1220. ;
  1221. EXCHERR:
  1222.     INC N5
  1223.     IF GT N5,20
  1224.        GOTO EXCHXIT
  1225.        ENDIF
  1226.     TRANSMIT "-!"
  1227.     GOTO EXCH100
  1228. ;
  1229. ;    End of exchange procedure
  1230. ;
  1231. EXCHXIT:
  1232.     REWIND            ; REWIND input file (us)
  1233.     FCLOSEO         ; Close (and flush) output file
  1234.     LEGEND S19        ; Restore
  1235.     RETURN            ; And return to caller
  1236. ;
  1237. ; ----- Subroutine: Command (and receive) a remote directory build
  1238. ;    .. Send a 'C' command to the remote
  1239. ;    .. On entry, S1 contains the new directory
  1240. ;
  1241. BuildRemDir:
  1242.     TRANSMIT "R"& S1 &"!"  ; Send the command
  1243.     RGET S1 80 20        ; 10 second timeout - read the line
  1244.     IF FAILURE        ; Timeout on read
  1245.        SOUND 100,100    ; Indicate problem
  1246.        GOTO BURDXIT     ; And exit
  1247.        ENDIF
  1248.     IF NOT STRCMP S1(0) "+" ; Test for an ACK
  1249.        SOUND 200,100    ; Indicate problem
  1250.        GOTO BURDXIT     ; And exit
  1251.        ENDIF
  1252. ;
  1253. ;    Receive the new directory
  1254. ;
  1255.     FOPENO "PC2PC.REM" TEXT ; Open remote directory, purge if need be
  1256.     IF FAILURE
  1257.        GOSUB Disc_Error
  1258.        ENDIF
  1259.     LEGEND "Waiting to receive new directory"
  1260.     N1 = 1            ; Set loop/position ctr
  1261.     N5 = 0            ; Error counter
  1262. ;
  1263. ;    Wait for a response
  1264. ;
  1265. BURD100:
  1266.     RGET S2 80 120        ; Wait 2 mins max response
  1267.     IF Failure        ; If timeout on read
  1268.        GOTO BURDXIT     ; Exit proc
  1269.        ENDIF
  1270. ;
  1271. ;    Perform a CRC check on the text
  1272. ;
  1273.     LENGTH S2 N3        ; Look at the received line length
  1274.     IF GT N3 1        ; If not just an ACK alone
  1275.        CRC S2(1:40) N2    ; COmpute CRC of text
  1276.        ATOI S2(41:46) N4    ; Convert CRC embedded
  1277.        IF NE N2 N4        ; IF CRC's don't match
  1278.           TRANSMIT "-!"     ; Transmit a NAK
  1279.           INC N5        ; Increment error cnt
  1280.           IF GT N5,20
  1281.          GOTO BURDXIT
  1282.          ENDIF
  1283.           GOTO BURD100    ; And wait again for re-send
  1284.           ENDIF
  1285.        N5 = 0        ; Reset counter
  1286.     ELSE            ; Only one char sent
  1287.        TRANSMIT "+!"        ; And acknowlege
  1288.        GOTO BURDXIT     ; Exit - end of transmit
  1289.        ENDIF
  1290. ;
  1291. ;    Write the information to disc, and display the line
  1292. ;
  1293.     IF GE (N99-5),N1    ; If within window
  1294.        ATSAY N1,41 (default) S2(1:36) ; And display
  1295.     ELSE
  1296.        IF EQ (N99-4) N1
  1297.           FSAVEI
  1298.           ENDIF
  1299.        LEGEND S19(0:19)&" Line "*N1&" received"
  1300.        ENDIF
  1301.     WRITE S2(1:40) 40    ; Write the line to disc too
  1302.     INC N1            ; Count the line
  1303.     TRANSMIT "+!"           ; And acknowlege
  1304.     GOTO BURD100        ; And continue
  1305. ;
  1306. ;    End of receive procedure
  1307. ;
  1308. BURDXIT:
  1309.     FCLOSEO         ; Close (and flush) output file
  1310.     REWIND            ; Rewind the input file
  1311.     LEGEND S19        ; Restore
  1312.     RETURN            ; And return to caller
  1313. ;
  1314. ; ----- Subroutine: Remote commanded change of subdir
  1315. ;    .. We received a 'C' command
  1316. ;    .. S1 on entry is the new subdirectory
  1317. ;
  1318. Remote_Chdir:
  1319.     FCLOSEI         ; Close input just in case
  1320.     DELETE "PC2PC.LOC"      ; Delete our directory
  1321.  
  1322.     CHDIR S1        ; Set a new subdirectory
  1323.  
  1324.     IF FLAG(2)        ; If we're on remote
  1325.        GOSUB Change_sides    ; Switch our side
  1326.        ENDIF
  1327.     GOSUB Clear_Window    ; Clear our window
  1328.     LEGEND " Remote requested chdir"
  1329.  
  1330.     GOSUB BuildLocDir    ; Build a new directory
  1331.  
  1332.     FOPENI "PC2PC.LOC" TEXT ; Open our directory
  1333.     IF FAILURE
  1334.        GOSUB Disc_Error
  1335.        ENDIF
  1336.     N1 = 1
  1337.     N5 = 0
  1338. ;
  1339. ;    Send a line from our file
  1340. ;
  1341. RECH100:
  1342.     READ S1 40 N2        ; Length read into N2
  1343.     IF EOF
  1344.        S1 = "!"             ; Make an cr line
  1345.        GOTO RECH110     ; And continue
  1346.        ENDIF
  1347.  
  1348.     CRC S1(0:39) N2     ; CRC what we read
  1349.     S1(40:50) = N2 &"!"     ; Place CRC and c/r into string
  1350. RECH110:
  1351.     TRANSMIT "+"&S1         ; Transmit the line with an ACK
  1352.     LEGEND S19(0:19)&" Line "*N1&" sent"
  1353. ;
  1354. ;    Wait for a response
  1355. ;
  1356. RECH200:
  1357.     RGET S2 80 60        ; Wait 60 secs for a response
  1358.     IF Failure        ; If timeout on read
  1359.        GOTO RECHXIT     ; Exit proc
  1360.        ENDIF
  1361. ;
  1362. ;    Handle received NAK
  1363. ;
  1364.     IF NOT STRCMP S2(0:0) "+" ; IF NAK received
  1365.        INC N5        ; Increment error cnt
  1366.        IF GT N5,20
  1367.           GOTO RECHXIT
  1368.           ENDIF
  1369.        GOTO RECH110     ; .. resend last line
  1370.        ENDIF
  1371.     INC N1            ; Count the line sent
  1372.     N5 = 0            ; OKay
  1373.     IF NOT EOF
  1374.        GOTO RECH100     ; Go for more
  1375.        ENDIF
  1376. ;
  1377. ;    End of remote exchange procedure
  1378. ;
  1379. RECHXIT:
  1380.     REWIND            ; REWIND input file (us)
  1381.     LEGEND S19        ; Restore
  1382.     RETURN            ; And return to caller
  1383. ;
  1384. ; ----- Subroutine: Create a new directory, and send it to the remote
  1385. ;    .. Send an 'L' command
  1386. ;    .. On entry, S1 contains the new subdir
  1387. ;
  1388. SendLocDir:
  1389.     CHDIR S1        ; Change directory
  1390.     GOSUB BuildLocDir    ; Redo the directory build
  1391. ;
  1392. ;    Send the command, and wait for an acknowlegement
  1393. ;
  1394.     TRANSMIT "L!"           ; Send the command
  1395.     RGET S1 80 10        ; 10 second timeout - read the line
  1396.     IF FAILURE        ; Timeout on read
  1397.        SOUND 100,100    ; Indicate problem
  1398.        GOTO SELDXIT     ; And exit
  1399.        ENDIF
  1400.     IF NOT STRCMP S1(0) "+" ; Test for an ACK
  1401.        SOUND 200,100    ; Indicate problem
  1402.        GOTO SELDXIT     ; And exit
  1403.        ENDIF
  1404.  
  1405.     FOPENI "PC2PC.LOC" TEXT ; Open our directory
  1406.     IF FAILURE
  1407.        GOSUB Disc_Error
  1408.        ENDIF
  1409.     N1 = 1
  1410. ;
  1411. ;    Send a line from our file
  1412. ;
  1413. SELD100:
  1414.     READ S1 40 N2        ; Length read into N2
  1415.     IF EOF
  1416.        S1 = "!"             ; Make an cr line
  1417.        GOTO SELD110     ; And continue
  1418.        ENDIF
  1419.  
  1420.     CRC S1(0:39) N2     ; CRC what we read
  1421.     S1(40:50) = N2 &"!"     ; Place CRC and c/r into string
  1422. SELD110:
  1423.     TRANSMIT "+"&S1         ; Transmit the line with an ACK
  1424.     LEGEND S19(0:19)&" Line "*N1&" sent"
  1425. ;
  1426. ;    Wait for a response
  1427. ;
  1428. SELD200:
  1429.     RGET S2 80 60        ; Wait 60 secs for a response
  1430.     IF Failure        ; If timeout on read
  1431.        GOTO SELDXIT     ; Exit proc
  1432.        ENDIF
  1433. ;
  1434. ;    Handle received NAK
  1435. ;
  1436.     IF NOT STRCMP S2(0:0) "+" ; IF NAK received
  1437.        GOTO SELD110     ; .. resend last line
  1438.        ENDIF
  1439.     INC N1            ; Count the line sent
  1440.     IF NOT EOF
  1441.        GOTO SELD100     ; Go for more
  1442.        ENDIF
  1443. ;
  1444. ;    End of remote exchange procedure
  1445. ;
  1446. SELDXIT:
  1447.     REWIND            ; REWIND input file (us)
  1448.     LEGEND S19        ; Restore
  1449.     RETURN            ; And return to caller
  1450. ;
  1451. ; ----- Subroutine: Receive a new 'remote' directory
  1452. ;    .. We received an 'L' command
  1453. ;
  1454. Local_Chdir:
  1455.     FCLOSEI         ; Close input just in case
  1456.     DELETE "PC2PC.REM"      ; Delete remote directory
  1457.  
  1458.     IF NOT FLAG(2)        ; If we're on 'our' side
  1459.        GOSUB Change_sides    ; Switch our side
  1460.        ENDIF
  1461.  
  1462.     FOPENO "PC2PC.REM" TEXT ; Open our directory
  1463.     IF FAILURE
  1464.        GOSUB Disc_Error
  1465.        ENDIF
  1466.  
  1467.     N1 = 1
  1468.     LEGEND "Remote is sending new listing"
  1469.     GOSUB Clear_Window    ; Clear our window
  1470. ;
  1471. ;    Wait for a response
  1472. ;
  1473. LOCH100:
  1474.     RGET S2 80 120        ; Wait 2 mins max response
  1475.     IF Failure        ; If timeout on read
  1476.        GOTO LOCHXIT     ; Exit proc
  1477.        ENDIF
  1478. ;
  1479. ;    Perform a CRC check on the text
  1480. ;
  1481.     LENGTH S2 N3        ; Look at the received line length
  1482.     IF GT N3 1        ; If not just an ACK alone
  1483.        CRC S2(1:40) N2    ; COmpute CRC of text
  1484.        ATOI S2(41:46) N4    ; Convert CRC embedded
  1485.        IF NE N2 N4        ; IF CRC's don't match
  1486.           TRANSMIT "-!"     ; Transmit a NAK
  1487.           GOTO LOCH100    ; And wait again for response
  1488.           ENDIF
  1489.     ELSE            ; Only one char sent
  1490.        TRANSMIT "+!"        ; And acknowlege
  1491.        GOTO LOCHXIT     ; Exit - end of transmit
  1492.        ENDIF
  1493. ;
  1494. ;    Write the information to disc, and display the line
  1495. ;
  1496.     IF GE (N99-5),N1    ; If within window
  1497.        ATSAY N1,41 (default) S2(1:36) ; And display
  1498.     ELSE
  1499.        IF EQ (N99-4) N1
  1500.           FSAVEI
  1501.           ENDIF
  1502.        LEGEND S19(0:19)&" Line "*N1&" received"
  1503.        ENDIF
  1504.     WRITE S2(1:40) 40    ; Write the line to disc too
  1505.     INC N1            ; Count the line
  1506.     TRANSMIT "+!"           ; And acknowlege
  1507.     GOTO LOCH100        ; And continue
  1508. ;
  1509. ;    End of receive procedure
  1510. ;
  1511. LOCHXIT:
  1512.     FCLOSEO         ; Close (and flush) output file
  1513.     FOPENI "PC2PC.REM"      ; Open remote again
  1514.     LEGEND S19        ; Restore
  1515.     RETURN            ; And return to caller
  1516. ;
  1517. ; ----- Subroutine: Wildcard send
  1518. ;
  1519. Wildcard:
  1520.     LEGEND " Enter a wildcard spec for file(s) "
  1521.     WOPEN 10, 1,12,77 (contrast) WILDEsc
  1522. ;
  1523. ;    First: Ask for send/receive
  1524. ;
  1525.     ATSAY 11, 3 (contrast) "You may send or receive files: Enter S/R:  "
  1526.     ATSAY 12,27 (contrast) " Press ESC to cancel "
  1527. WILD100:
  1528.     ATGET 11,45 (contrast) 1 S1
  1529.     IF NULL S1
  1530.        GOTO WILDXIT     ; And exit
  1531.        ENDIF
  1532.     SWITCH S1
  1533.        CASE "S"
  1534.           SET FLAG(9) ON
  1535.        ENDCASE
  1536.        CASE "R"
  1537.           SET FLAG(9) OFF
  1538.        ENDCASE
  1539.        DEFAULT
  1540.           SOUND 100,100
  1541.           GOTO WILD100
  1542.        ENDCASE
  1543.     ENDSWITCH
  1544. ;
  1545. ;    Now, ask for a wildcard spec
  1546. ;
  1547. WILD200:
  1548.     BOX  10, 1,12,77 (contrast) ; Clear the window
  1549.     ATSAY 11, 3 (contrast) "Wildcard file spec: "
  1550.     ATSAY 12,27 (contrast) " Press ESC to cancel "
  1551.  
  1552.     ATGET 11,24 (contrast) 50 S1
  1553.     IF NULL S1
  1554.        GOTO WILDXIT     ; And exit
  1555.        ENDIF
  1556.     IF FLAG (9)        ; If sending
  1557.        FFIRST S1        ; Test for files available
  1558.        IF FAILED
  1559.           S1 = "No files match the given spec"
  1560.           GOSUB TranErr
  1561.           GOTO WILD200
  1562.           ENDIF
  1563.        TRANSMIT "WR!"       ; Send the command
  1564.     ELSE
  1565.        TRANSMIT "WS"& S1 &"!"
  1566.        ENDIF
  1567. ;
  1568. ;    Send the a command to remote, and wait for an acknowlegement
  1569. ;
  1570. WILD300:
  1571.     RGET S2 80 10        ; 10 second timeout - read the line
  1572.     IF FAILURE        ; Timeout on read
  1573.        S1 = "Remote has failed to acknowlege"
  1574.        GOSUB TranErr
  1575.        GOTO WILDXIT     ; And exit
  1576.        ENDIF
  1577.     IF NOT STRCMP S2(0) "+" ; Test for an ACK
  1578.        IF FLAG(9)
  1579.           GOTO WILD300    ; Try again
  1580.        ELSE
  1581.           S1 = "Sender reports no files matching your spec"
  1582.           GOSUB TranErr
  1583.           ENDIF
  1584.        GOTO WILDXIT     ; And exit
  1585.        ENDIF
  1586. ;
  1587. ;    Set-up our send/receive
  1588. ;
  1589.     IF FLAG(9)
  1590. ;       SENDFILE BYMODEM S1
  1591.        SENDFILE KERMIT  S1
  1592.     ELSE
  1593. ;       GETFILE BYMODEM
  1594.        GETFILE KERMIT
  1595.        ENDIF
  1596.     IF FAILED
  1597.        S1 = "Transfer has failed"
  1598.        GOSUB TranErr
  1599.        ENDIF
  1600. ;
  1601. ;    Exit the wildcard send
  1602. ;
  1603. WILDXIT:
  1604.     WCLOSE            ; Close open window
  1605.     LEGEND S19        ; Restore
  1606.     RETURN            ; And return to caller
  1607. ;
  1608. ;    Escape during "WILDCARD" window
  1609. ;
  1610. WILDEsc:
  1611.     S1 = ""                 ; Make a null return
  1612.     RETURN            ; And return to KEYGET above
  1613. ;
  1614. ; ----- Subroutine: Transfer error
  1615. ;    .. Open a window, display, and and await keypress
  1616. ;    S1 passes the message to display
  1617. ;    S11 is used to save ON ESCAPE, as this window is opened on another
  1618. ;
  1619. TranErr:
  1620.     S11 = "_ONESCAPE"               ; Save label previously set
  1621.     ON ESCAPE GOSUB TranEsc     ; Escape out of pop-up
  1622.  
  1623.     SAVE 10, 1,12,77
  1624.     BOX  10, 1,12,77 (contrast)
  1625.  
  1626.     ATSAY 11, 3 (contrast) S1
  1627.     ATSAY 12,26 (contrast) " Press any key to continue "
  1628.     SOUND 880,100
  1629.  
  1630.     KEYGET S0        ; Wait for any key
  1631.     ON ESCAPE GOSUB S11    ; Reset original ON ESCAPE label
  1632.     RESTORE         ; Restore screen under
  1633.     RETURN            ; And return to caller
  1634. ;
  1635. ;    Escape during "TranErr" window
  1636. ;
  1637. TranEsc:
  1638.     RETURN            ; And return to KEYGET above
  1639. ;
  1640. ; ----- Subroutine: Remote wildcard receive/send
  1641. ;    S1 contains the command ("WR" or "WS<spec>")
  1642. ;
  1643. Rcv_Wildcard:
  1644.     IF STRCMP S1(0) "S"
  1645.        FFIRST S1(1:79)    ; Test for files available
  1646.        IF FAILED
  1647.           TRANSMIT "-!"     ; Send a NAK
  1648.           RETURN
  1649.           ENDIF
  1650.        ENDIF
  1651. ;
  1652. ;    Acknowlege, and set-up the transfer
  1653. ;
  1654.     TRANSMIT "+!"
  1655.     IF STRCMP S1(0) "R"
  1656. ;       GETFILE BYMODEM
  1657.        GETFILE KERMIT
  1658.     ELSE
  1659. ;       SENDFILE BYMODEM S1(1:79)
  1660.        SENDFILE KERMIT  S1(1:79)
  1661.        ENDIF
  1662.     IF FAILED
  1663.        SOUND 880,500
  1664.        ENDIF
  1665.     RETURN
  1666. ;
  1667. ; ----- Subroutine: Select a file for transfer
  1668. ;
  1669. Select:
  1670.     IF FLAG(2)        ; We're on remote side
  1671.        N10 = N92
  1672.     ELSE
  1673.        N10 = N91
  1674.        ENDIF
  1675.  
  1676.     S10 = "_ONESCAPE"
  1677.     ON ESCAPE GOSUB SELEEsc
  1678. ;
  1679. ;    Open a window, and show current selections
  1680. ;
  1681.     LEGEND " Transfer selections"
  1682.     SAVE 8,10,20,70     ; Save for restore
  1683.     GOSUB Read_Cursor
  1684. ;
  1685. ;    Clear and redisplay
  1686. ;
  1687. SELE100:
  1688.     BOX  8,10,20,70 (contrast)
  1689.  
  1690.     ATSAY  9,12 (contrast) "   Local files selected     Remote files selected"
  1691.     ATSAY 11,12 (contrast) "1) "*S16(0:12)
  1692.     ATSAY 12,12 (contrast) "2) "*S16(13:25)
  1693.     ATSAY 13,12 (contrast) "3) "*S16(26:38)
  1694.     ATSAY 14,12 (contrast) "4) "*S16(39:51)
  1695.     ATSAY 15,12 (contrast) "5) "*S16(52:64)
  1696.  
  1697.     ATSAY 11,40 (contrast) "a) "*S15(0:12)
  1698.     ATSAY 12,40 (contrast) "b) "*S15(13:25)
  1699.     ATSAY 13,40 (contrast) "c) "*S15(26:38)
  1700.     ATSAY 14,40 (contrast) "d) "*S15(39:51)
  1701.     ATSAY 15,40 (contrast) "e) "*S15(52:64)
  1702.  
  1703.     IF LT N10 5 OR NULL S12
  1704.        ATSAY 17,12 (contrast) "Current cursor points to: "*S12(0:12)
  1705.        ATSAY 18,12 (contrast) "Do you wish to add this file (Y/N)?"
  1706.     ELSE
  1707.        ATSAY 17,12 (contrast) "No more files may be selected from this side"
  1708.        ATSAY 18,12 (contrast) "Enter a letter or number from above to clear an entry"
  1709.        ENDIF
  1710.     ATSAY 19,12 (Contrast) "Select: "
  1711.     ATSAY 20,28 (Contrast) " Press ESC to exit "
  1712. ;
  1713. ;    Read the kbd for a response
  1714. ;
  1715. SELE200:
  1716.     LOCATE    19,20
  1717.     KEYGET S1        ; Wait for any key
  1718.     SWITCH S1
  1719.        CASE "_NULL"
  1720.           GOTO SELEXIT
  1721.        ENDCASE
  1722.        CASE "Y"
  1723.           GOTO SELE500
  1724.        ENDCASE
  1725.        CASE "N"
  1726.           GOTO SELEXIT
  1727.        ENDCASE
  1728.  
  1729.        CASE "1"
  1730.           S16(0:79) = S16(13:79)
  1731.           GOTO SELE300
  1732.        ENDCASE
  1733.        CASE "2"
  1734.           S16(13:79) = S16(26:79)
  1735.           GOTO SELE300
  1736.        ENDCASE
  1737.        CASE "3"
  1738.           S16(26:79) = S16(39:79)
  1739.           GOTO SELE300
  1740.        ENDCASE
  1741.        CASE "4"
  1742.           S16(39:79) = S16(52:79)
  1743.           GOTO SELE300
  1744.        ENDCASE
  1745.        CASE "5"
  1746.           S16(52:79) = S16(65:79)
  1747.           GOTO SELE300
  1748.        ENDCASE
  1749.  
  1750.        CASE "A"
  1751.           S15(0:79) = S15(13:79)
  1752.           GOTO SELE400
  1753.        ENDCASE
  1754.        CASE "B"
  1755.           S15(13:79) = S15(26:79)
  1756.           GOTO SELE400
  1757.        ENDCASE
  1758.        CASE "C"
  1759.           S15(26:79) = S15(39:79)
  1760.           GOTO SELE400
  1761.        ENDCASE
  1762.        CASE "D"
  1763.           S15(39:79) = S15(52:79)
  1764.           GOTO SELE400
  1765.        ENDCASE
  1766.        CASE "E"
  1767.           S15(52:79) = S15(65:79)
  1768.           GOTO SELE400
  1769.        ENDCASE
  1770.  
  1771.        DEFAULT        ; Direct
  1772.          SOUND 100,100    ; Signal displeasure
  1773.          GOTO SELE200
  1774.        ENDCASE
  1775.     ENDSWITCH
  1776. ;
  1777. ;    Deleted a file from the local side
  1778. ;
  1779. SELE300:
  1780.     IF NOT ZERO N10
  1781.        DEC N91
  1782.        DEC N10
  1783.        ENDIF
  1784.     GOTO SELE100
  1785. ;
  1786. ;    Deleted a file from the remote side
  1787. ;
  1788. SELE400:
  1789.     IF NOT ZERO N10
  1790.        DEC N92
  1791.        DEC N10
  1792.        ENDIF
  1793.     GOTO SELE100
  1794. ;
  1795. ;    "Y" was entered
  1796. ;
  1797. SELE500:
  1798.     IF LT N10 5
  1799.        IF FLAG(2)        ; On remote side
  1800.           S15(N10*13:79) = S12(0:12)
  1801.           INC N10
  1802.           INC N92
  1803.        ELSE
  1804.           S16(N10*13:79) = S12(0:12)
  1805.           INC N10
  1806.           INC N91
  1807.           ENDIF
  1808.     ELSE
  1809.        SOUND 100,100
  1810.        GOTO SELE200
  1811.        ENDIF
  1812. ;
  1813. ;    The above case never falls through
  1814. ;
  1815. SELEXIT:
  1816.     ON ESCAPE GOSUB S10
  1817.     RESTORE
  1818.     RETURN
  1819. ;
  1820. ;    ESCAPE entered during select
  1821. ;
  1822. SELEESC:
  1823.     S1 = ""
  1824.     RETURN
  1825. ;
  1826. ; ----- Subroutine: Transfer selected files
  1827. ;
  1828. Transfer:
  1829.     IF ZERO N91 and ZERO N92
  1830.        S1 = "You have not selected a file to transfer"
  1831.        GOSUB TranErr
  1832.        RETURN
  1833.        ENDIF
  1834.  
  1835.     WOPEN 10,1 12,77 (contrast)
  1836.     ATSAY 11,3 (contrast) "Transfer in progress"
  1837. ;
  1838. ;    Send any files from the local side
  1839. ;
  1840. TRAN100:
  1841.     IF ZERO N91
  1842.        GOTO TRAN200
  1843.        ENDIF
  1844.  
  1845.     TRANSMIT "TR"& S16(0:12) &"!"   ; Command remote to receive
  1846. ;
  1847. ;    Send the a command to remote, and wait for an acknowlegement
  1848. ;
  1849. TRAN110:
  1850.     RGET S2 80 10        ; 10 second timeout - read the line
  1851.     IF FAILURE        ; Timeout on read
  1852.        S1 = "Remote has failed to acknowlege"
  1853.        GOSUB TranErr
  1854.        GOTO TRAN300     ; And exit
  1855.        ENDIF
  1856.     IF NOT STRCMP S2(0) "+" ; Test for an ACK
  1857.        GOTO TRAN110     ; Try again
  1858.        ENDIF
  1859. ;    SENDFILE XMODEM S16(0:12)
  1860.     SENDFILE wXMODEM S16(0:12)
  1861.     IF FAILED
  1862.        S1 = "Transfer has failed"
  1863.        GOSUB TranErr
  1864.        GOTO TRAN300
  1865.        ENDIF
  1866.     S16(0:79) = S16(13:79)
  1867.     DEC N91
  1868.     GOTO TRAN100
  1869. ;
  1870. ;    Receive any files from the remote side
  1871. ;
  1872. TRAN200:
  1873.     IF ZERO N92
  1874.        GOTO TRAN300
  1875.        ENDIF
  1876.  
  1877.     TRANSMIT "TS"& S15(0:12) &"!"   ; Command remote to send
  1878. ;
  1879. ;    Send the a command to remote, and wait for an acknowlegement
  1880. ;
  1881. TRAN210:
  1882.     RGET S2 80 10        ; 10 second timeout - read the line
  1883.     IF FAILURE        ; Timeout on read
  1884.        S1 = "Remote has failed to acknowlege"
  1885.        GOSUB TranErr
  1886.        GOTO TRAN300     ; And exit
  1887.        ENDIF
  1888.     IF NOT STRCMP S2(0) "+" ; Test for an ACK
  1889.        GOTO TRAN210     ; Try again
  1890.        ENDIF
  1891.     DELETE S15(0:12)
  1892. ;    GETFILE XMODEM S15(0:12)
  1893.     GETFILE wXMODEM S15(0:12)
  1894.     IF FAILED
  1895.        S1 = "Transfer has failed"
  1896.        GOSUB TranErr
  1897.        GOTO TRAN300
  1898.        ENDIF
  1899.     S15(0:79) = S15(13:79)
  1900.     DEC N92
  1901.     GOTO TRAN200
  1902. ;
  1903. ;    Close the window opened above
  1904. ;
  1905. TRAN300:
  1906.     WCLOSE
  1907. ;
  1908. ;    And we're done
  1909. ;
  1910. TRANXIT:
  1911.     RETURN
  1912. ;
  1913. ; ----- Subroutine: Remote transfer receive/send
  1914. ;    S1 contains the command ("TR<file>" or "TS<file>")
  1915. ;
  1916. Rcv_Transfer:
  1917.     TRANSMIT "+!"
  1918.     IF STRCMP S1(0) "R"
  1919.        DELETE S1(1:13)
  1920. ;       GETFILE XMODEM S1(1:13)
  1921.        GETFILE wXMODEM S1(1:13)
  1922.     ELSE
  1923. ;       SENDFILE XMODEM S1(1:13)
  1924.        SENDFILE wXMODEM S1(1:13)
  1925.        ENDIF
  1926.     IF FAILED
  1927.        SOUND 880,500
  1928.        ENDIF
  1929.     RETURN
  1930. ;
  1931. ; ----- Subroutine: Draw the basic screen box
  1932. ;
  1933. InitScreen:
  1934.     SSIZE N99
  1935.     SAVE 0,0,N99-2,79
  1936.  
  1937.     BOX   0, 0, (N99-2) ,78 (default)
  1938.  
  1939.     ATSAY 0, 18 (default) " Local "
  1940.     ATSAY 0, 35 (default) " PC-2-PC "
  1941.     ATSAY 0, 56 (default) " Remote "
  1942.  
  1943.     FOR N19 = 1 (N99-5) 1
  1944.         ATSAY N19 39 (default) "│"
  1945.         ENDFOR
  1946.  
  1947.     ATSAY N99-4,0  (default) "├─────────────────────────────────────────────────────────────────────────────┤"
  1948.     ATSAY N99-4,39 (default) "┴"
  1949.  
  1950.     ATSAY N99-4,9  (default) " , , PgUp, PgDn "
  1951.     ATSAY N99-4,48 (default) "  to this window "
  1952.     ATSAY N99-3,2  (Default) "H)elp, E)xit, C)hdir, W)ildcard, S)elect, T)ransfer and Alt-F10:"
  1953.     ATSAY N99-2,28 (Default) " Press ESC to terminate "
  1954.     RETURN
  1955. ;
  1956. ; ----- Subroutine: Help
  1957. ;
  1958. Help:
  1959.     SAVE  0 , 0,24,78
  1960.     BOX   0 , 0,24,78 (default)
  1961.  
  1962.     ATSAY  0, 2 (Default) " PC-2-PC "
  1963.     ATSAY 24,28 (Default) " Press any key to continue "
  1964.  
  1965.     S10 = "_ONESCAPE"
  1966.     ON ESCAPE GOSUB HELPESC
  1967.  
  1968.     IF FLAG(0)
  1969.        GOTO HELP100
  1970.        ENDIF
  1971. ;
  1972. ;    Help message prior to establishing link
  1973. ;
  1974.     ATSAY  1,2 (default) "PC-2-PC is a COM-AND script for linking PCs and exchanging files.  When    "
  1975.     ATSAY  2,2 (default) "PC-2-PC executed, it reads and displays the current subdirectory, and then  "
  1976.     ATSAY  3,2 (default) "prompts for a method to establish a link."
  1977.  
  1978.     ATSAY  5,2 (default) "Two link methods are provided, either DIRECT connect, or CALLing through    "
  1979.     ATSAY  6,2 (default) "the dialing directory.  Each method has two sides: one that initiates the   "
  1980.     ATSAY  7,2 (default) "connection, and one that awaits a connection.  The first script loaded (or  "
  1981.     ATSAY  8,2 (default) "the first PC to be loaded) is best instructed to 'await'.  The second to    "
  1982.     ATSAY  9,2 (default) "be loaded may then initiate the connection."
  1983.  
  1984.     ATSAY 11,2 (default) "A direct connection is, for example, an RS232 cable between async ports     "
  1985.     ATSAY 12,2 (default) "of two PCs.  The RS232 cable must be configured as a 'null modem' - i.e.,   "
  1986.     ATSAY 13,2 (default) "the send side of one PC must connect to the receive side of the other and   "
  1987.     ATSAY 14,2 (default) "vice versa.  As PC-2-PC ignores carrier using this method, even 3-wire      "
  1988.     ATSAY 15,2 (default) "null modem will work."
  1989.  
  1990.     ATSAY 17,2 (default) "A called connection uses a modem on each PC, and the dialing directory      "
  1991.     ATSAY 18,2 (default) "on one of them.  The modems must be able to communicate ordinarily (not     "
  1992.     ATSAY 19,2 (default) "all do).  The initiator of the called connection selects the dialing        "
  1993.     ATSAY 20,2 (default) "directory entry number (with or without LD prefix), and COM-AND dials       "
  1994.     ATSAY 21,2 (default) "in the ordinary fashion.  The PC awaiting the connect answers the call.     "
  1995.  
  1996.     ATSAY 23,2 (default) "Once connection has been established, the PC's exchange directory lists.    "
  1997.     GOTO HELPXIT
  1998. ;
  1999. ;    Help message after link established
  2000. ;
  2001. HELP100:
  2002.     ATSAY  1,2 (default) "The two PC's are connected, and directory listings have been exchanged.     "
  2003.     ATSAY  2,2 (default) "The left window is the current subdirectory on this PC.  The right window   "
  2004.     ATSAY  3,2 (default) "is the current directory on the remote.  Cursor-keys (left/right) change    "
  2005.     ATSAY  4,2 (default) "the 'active' window - you are either in the left or right windows."
  2006.  
  2007.     ATSAY  5,2 (default) "The 'C'hdir command will select a new drive:subdirectory on this PC (if     "
  2008.     ATSAY  6,2 (default) "the left window is active), and on the remote PC (if right window).         "
  2009.     ATSAY  7,2 (default) "The active window on the remote PC is switched (if need be) and a new       "
  2010.     ATSAY  8,2 (default) "list is displayed on both PC's."
  2011.  
  2012.     ATSAY 10,2 (default) "PgUp, PgDn, Home and End allow paging through the active window for files.  "
  2013.     ATSAY 11,2 (default) "Only paging is performed - the window is not scrolled line by line."
  2014.  
  2015.     ATSAY 13,2 (default) "Cursor-Up and Cursor-Down highlight files on the current page.  A lighted   "
  2016.     ATSAY 14,2 (default) "line is selected for transfer with 'S'elect.  Up to 5 files on the local    "
  2017.     ATSAY 15,2 (default) "side, and 5 files on the remote side may be selected.  A 'T'ransfer may be  "
  2018.     ATSAY 16,2 (default) "done at any time to transfer files (either from or to the local PC). "
  2019.  
  2020.     ATSAY 17,2 (default) "A wildcard file transfer is also available, selecting files to/from other   "
  2021.     ATSAY 18,2 (default) "than the current subdirectory, or where a template might make life easier.  "
  2022.     ATSAY 19,2 (default) "Unlike the 'T'ransfer command, you transfer using a wildcard only one       "
  2023.     ATSAY 20,2 (default) "direction at a time, either sending or receiving. "
  2024.  
  2025.     ATSAY 22,2 (default) "If you have selected files, you must transfer them before changing sub-     "
  2026.     ATSAY 23,2 (default) "directories.  E)xit terminates both sides if a called connected was made."
  2027.     GOTO HELPXIT
  2028. ;
  2029. ;    Wait for a keypress, and exit
  2030. ;
  2031. HELPXIT:
  2032.     KEYGET S0
  2033.  
  2034.     ON ESCAPE GOSUB S10
  2035.     RESTORE
  2036.     RETURN
  2037. ;
  2038. ;    ESCAPE pressed during the HELP
  2039. ;
  2040. HELPESC:
  2041.     RETURN
  2042.